import axios  from "axios";
import { Notification } from "element-ui";
// import { config } from "vue/types/umd";

let request=axios.create({
    timeout:60000
})

//请求拦截
//发送请求时做的事情
request.interceptors.request.use(config=>{
    config.headers['shopping-admin-token']=sessionStorage.getItem('shopping-admin-token')
    console.log('config',config)
    return config
})
//返回拦截
request.interceptors.response.use(response=>{
    console.log('返回信息',response)

    if(response.data.errno===501){
        Notification.error({
            title:'请登录'
        })
        return Promise.reject('error')
    }else{
        return response
    }
})
export default request